package com.hnevc.xiewenguang;

import java.util.Scanner;

public class Example01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("输入第一个字符串:");
        String s1 = sc.next();
        System.out.print("输入第二个字符串:");
        String s2 = sc.next();
        System.out.println(HA(s1, s2));
    }
    public static int HA(String s1,String s2){
        int index =0;
        int length = s2.length();  //字符串的长度
        int count =0;  //包含的个数
        while(index < s1.length()){
            if(s1.indexOf(s2,index) != -1){
                index = s1.indexOf(s2,index)+length;
                count ++;   //包含的个数加1
            }else{
                break;
            }
        }
        return count;
    }
}
